﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BdClient;

namespace Univer
{
    public partial class AddNewCarForm : Form
    {
        private readonly BdExecute _execute;
        public AddNewCarForm()
        {
            _execute = new BdExecute();
            InitializeComponent();
            checkBox1.Text = _execute.GetPropertyCar().ToArray()[0].Description;
            checkBox2.Text = _execute.GetPropertyCar().ToArray()[1].Description;
            checkBox3.Text = _execute.GetPropertyCar().ToArray()[2].Description;
            checkBox4.Text = _execute.GetPropertyCar().ToArray()[3].Description;
            checkBox5.Text = _execute.GetPropertyCar().ToArray()[4].Description;
            checkBox6.Text = _execute.GetPropertyCar().ToArray()[5].Description;

        }

        private void button1_Click(object sender, EventArgs e)
        {
          decimal id=  _execute.AddCar(_execute.AddMark(textBox1.Text), Convert.ToDecimal( textBox4.Text), Convert.ToDecimal(textBox2.Text));
            if (checkBox1.Checked)
                _execute.AddPropertyCar(id,1);
            if (checkBox2.Checked)
                _execute.AddPropertyCar(id, 2);
            if (checkBox3.Checked)
                _execute.AddPropertyCar(id, 3);
            if (checkBox4.Checked)
                _execute.AddPropertyCar(id, 4);
            if (checkBox5.Checked)
                _execute.AddPropertyCar(id, 4);
            if (checkBox6.Checked)
                _execute.AddPropertyCar(id, 5);
        }
    }
}
